<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>投票后台管理</title>
  <link rel="stylesheet" href="/styles.css" />
  <script defer src="/admin.js"></script>
</head>
<body>
  <header class="admin-header">
    <h1>投票后台管理</h1>
  </header>
  <main class="admin-main">
    <section id="loginSection" class="admin-card admin-login-card">
      <h2>管理员登录</h2>
      <form id="loginForm" class="admin-form">
        <input type="text" id="username" placeholder="账号" required autocomplete="username" />
        <input type="password" id="password" placeholder="密码" required autocomplete="current-password" />
        <button type="submit" class="admin-btn admin-btn-primary">登录</button>
      </form>
      <div id="loginFeedback" class="feedback"></div>
    </section>
    <section id="adminPanel" class="admin-card" style="display:none;max-width:520px;margin:auto;">
      <h2 class="admin-section-title">发起新投票</h2>
      <div class="admin-card admin-subcard">
        <form id="createVoteForm" class="admin-form">
          <label class="admin-label">投票名称：</label>
          <input id="newVoteName" class="admin-input" placeholder="请输入投票名称" required />
          <label class="admin-label">投票选项（每行一个）：</label>
          <textarea id="newVoteOptions" rows="4" class="admin-textarea" placeholder="每行一个选项" required></textarea>
          <label class="admin-label">投票开始时间：</label>
          <input type="datetime-local" id="newVoteStart" class="admin-input" required />
          <label class="admin-label">投票截止时间：</label>
          <input type="datetime-local" id="newVoteEnd" class="admin-input" required />
          <button type="submit" class="admin-btn admin-btn-primary">设置投票</button>
        </form>
      </div>
      <div class="admin-card admin-subcard">
        <div class="admin-flex-row">
          <h3 class="admin-section-title" style="margin:0;">投票列表</h3>
          <button id="refreshVoteList" class="admin-btn admin-btn-small">刷新</button>
        </div>
        <ul id="voteListUl" style="margin:8px 0 0 0;padding:0;list-style:none;"></ul>
      </div>
      <div class="admin-card admin-subcard" id="voteDetailCard" style="display:none;">
        <div class="admin-flex-row">
          <h3 class="admin-section-title" id="voteDetailTitle" style="margin:0;"></h3>
          <button id="refreshResults" class="admin-btn admin-btn-small">刷新</button>
        </div>
        <div id="results" class="admin-results"></div>
        <button id="exportBtn" class="admin-btn admin-btn-small">导出投票记录</button>
      </div>
      <div id="adminFeedback" class="feedback"></div>
    </section>
  </main>
</body>
</html>
